
<fieldset class="layui-elem-field layui-field-title">
    <legend>个人简历</legend>
</fieldset>
<div class="layui-collapse" lay-accordion>
    <!--内容-->
</div>

<script>
    $(function(){
        GetDataList();
    });

    //获取技能列表
    function GetDataList(){
        var url = '/handler/blog/getResumeList';
        var data = {};
        dink.post(url,data,function(res){
            var target = $('.layui-collapse');
            var html = '';
            var typeArr = ['','编程技能','设计技能','办公技能','业余爱好'];
            var levelArr = ['','了解','熟悉','掌握','精通','大师'];
            if(res.ret == 1){
                if(res.skill.length > 0){
                    html += '<div class="layui-colla-item">';
                    html += '<h2 class="layui-colla-title">个人技能</h2>';
                    html += '<div class="layui-colla-content layui-show">';
                    $.each(res.skill,function(i,ele){
                        html += '<div class="layui-btn-group">\n' +
                            '  <button class="operate layui-btn '+( ele.sort==1 ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="up">\n' +
                            '    <i class="layui-icon">&#xe619;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn '+( ele.sort==res.skill.length ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="down">\n' +
                            '    <i class="layui-icon">&#xe61a;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn layui-btn-normal layui-btn-sm" data-id="'+ele.id+'" operate-type="delete">\n' +
                            '    <i class="layui-icon">&#xe640;</i>\n' +
                            '  </button>\n' +
                            '</div>';
                        html += '<span class="item">'+ele.skill_title+'</span>';
                        html += '<span class="item">'+typeArr[ele.skill_type]+'</span>';
                        html += '<span class="item">'+levelArr[ele.skill_level]+'</span>';
                        html += '<hr>';
                    });
                    html += '</div></div>';
                }
                if(res.experience.length > 0){
                    html += '<div class="layui-colla-item">';
                    html += '<h2 class="layui-colla-title">工作经历</h2>';
                    html += '<div class="layui-colla-content">';
                    $.each(res.experience,function(i,ele){
                        html += '<div class="layui-btn-group">\n' +
                            '  <button class="operate layui-btn '+( ele.sort==1 ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="up">\n' +
                            '    <i class="layui-icon">&#xe619;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn '+( ele.sort==res.experience.length ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="down">\n' +
                            '    <i class="layui-icon">&#xe61a;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn layui-btn-normal layui-btn-sm" data-id="'+ele.id+'" operate-type="delete">\n' +
                            '    <i class="layui-icon">&#xe640;</i>\n' +
                            '  </button>\n' +
                            '</div>';
                        html += '<span class="item">'+dink.utd(ele.start_time).substr(0,7).replace('-','/')+' - '+dink.utd(ele.end_time).substr(0,7).replace('-','/')+'</span>';
                        html += '<span class="item">'+ele.company_name+'</span>';
                        html += '<span class="item">'+ele.job_name+'</span>';
                        html += '<span class="item">'+ele.job_content+'</span>';
                    });
                    html += '</div></div>';
                }
                if(res.education.length > 0){
                    html += '<div class="layui-colla-item">';
                    html += '<h2 class="layui-colla-title">教育经历</h2>';
                    html += '<div class="layui-colla-content">';
                    $.each(res.education,function(i,ele){
                        html += '<div class="layui-btn-group">\n' +
                            '  <button class="operate layui-btn '+( ele.sort==1 ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="up">\n' +
                            '    <i class="layui-icon">&#xe619;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn '+( ele.sort==res.education.length ? 'layui-btn-disabled' : 'layui-btn-normal')+' layui-btn-sm" data-id="'+ele.id+'" operate-type="down">\n' +
                            '    <i class="layui-icon">&#xe61a;</i>\n' +
                            '  </button>\n' +
                            '  <button class="operate layui-btn layui-btn-normal layui-btn-sm" data-id="'+ele.id+'" operate-type="delete">\n' +
                            '    <i class="layui-icon">&#xe640;</i>\n' +
                            '  </button>\n' +
                            '</div>';
                        html += '<span class="item">'+dink.utd(ele.start_time).substr(0,7).replace('-','/')+' - '+dink.utd(ele.end_time).substr(0,7).replace('-','/')+'</span>';
                        html += '<span class="item">'+ele.school_name+'</span>';
                        html += '<span class="item">'+ele.major_name+'</span>';
                        html += '<span class="item">'+ele.major_content+'</span>';
                    });
                    html += '</div></div>';
                }
            }else{
                html = res.msg;
            }
            target.html(html);
            layui.use('element',function(){
                layui.element.render();
            });
        });
    }

    //操作按钮click事件
    dink.click('.operate',function(){
        var operate_type = $(this).attr('operate-type');
        var id = $(this).attr('data-id');
        //判断权限
        dink.post('/handler/permission/checkOperatePermission',{permission:'love:photo:'+operate_type},function(res){
            if(res.ret == 1){
                AdminNewsOpreate(operate_type,id,root,nickname,role_id);
            }else{
                layer.msg(res.msg);return;
            }
        });
        //end
    });

    //添加/编辑新闻
    function AdminNewsOpreate(operate='add',id=0){
        if(operate == 'add'){
            dink.html('AdminLovePhotoAdd','添加照片',['100%','100%']);
        }else if(operate == 'delete'){
            dink.alert('Tips','确定删除？',function(){
                dink.post('/handler/love/deletePhoto',{id:id},function(res){
                    layer.msg(res.msg);
                    GetTableList();return;
                });
            });
        }else{
            layer.msg('操作类型异常');return;
        }
        //添加、编辑
        dink.click('#add',function(){
            var data = {};
            var base = {};
            if(operate == 'add'){
                var url = '/handler/love/addPhoto';
            }else{
                layer.msg('操作类型异常');return;
            }
            var imageArr = [];
            $('.upload_item').each(function(i,ele){
                if($(ele).children().eq(2).text() == '上传成功'){
                    var item = {};
                    item.title = $(ele).attr('data-title');
                    item.size = $(ele).attr('data-size');
                    item.cover = $(ele).attr('data-url');
                    imageArr.push(item);
                }
            });
            if(imageArr.length == 0){
                layer.msg('无有效上传图片');return;
            }
            //end
            data.base = imageArr;
            dink.alert('Tips','确定'+(operate=='add' ? '添加' : '编辑')+'照片？',function(){
                dink.post(url,data,function(res){
                    if(res.ret == 1){
                        dink.close(res.msg);
                        GetTableList();
                    }else{
                        layer.msg(res.msg);
                    }
                });
            });
        });
    }
</script>

<style>
    .item{display:inline-block;margin-left:20px;width:150px;}
</style>